import java.sql.*;

public class JdbcException {
    private static Connection s_pConnect;
    private static Statement s_pStatement;
    private static Savepoint s_pSavePoint;

    public static void main(String[] args) {
        try {
            Class.forName(Const.JDBC_DRIVER);
            s_pConnect = DriverManager.getConnection(Const.MYSQL_URL, Const.USER_NAME, Const.USER_PASSWORD);
            s_pStatement = s_pConnect.createStatement();

            String strInsertSql = "INSERT INTO simpleTable VALUE(null, '老王', 40, '打牌')";
            int iRows = s_pStatement.executeUpdate(strInsertSql);

        } catch (SQLException e1) {
            e1.getErrorCode();   //获取错误码
            e1.getMessage();       //获取数据库驱动错误，或者 SQL 错误代码及消息
            e1.getSQLState();   //获取XOPEN SQLstate字符串。驱动错误不会被该异常捕捉

        } catch (Exception e2) {
            e2.printStackTrace();

        } finally {
            try {
                if (s_pStatement != null) {
                    s_pStatement.close();
                }

                if (s_pConnect != null) {
                    s_pConnect.close();
                }
            } catch (Exception e) {

            }
        }
    }
}
